import java.util.Arrays;

public class MyStack {
public int[] elem;
public int usedSize;

    public MyStack(int[] elem) {
        this.elem =new int[2];
    }

    public boolean isFull(){
    return elem.length==usedSize;
}
public boolean isEmpty(){
    return usedSize==0;
}
public void push(int val){
    if (isFull()){
        //如果满的话就进行扩容操作
        this.elem= Arrays.copyOf(elem,2*elem.length);
    }
    elem[usedSize]=val;
    usedSize++;
}
public int pop(){
        if (isEmpty()){
            return -1;
        }
        int ret=elem[usedSize-1];
        usedSize--;
        return ret;
}
public int peek(){
        if (isEmpty()){
            return -1;
        }
        return elem[usedSize-1];

}
public int size(){
        return usedSize;
}
}

